# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=hunspell-en
pkgver=2019.10.06
pkgrel=0
pkgdesc="English hunspell dictionaries"
url="http://wordlist.aspell.net/dicts/"
arch="noarch"
license="LGPL-2.0-or-later scowl"
subpackages="$pkgname-doc"
options="!check" # data only package
source="https://downloads.sourceforge.net/project/wordlist/speller/$pkgver/hunspell-en_US-$pkgver.zip
	https://downloads.sourceforge.net/project/wordlist/speller/$pkgver/hunspell-en_CA-$pkgver.zip
	https://downloads.sourceforge.net/project/wordlist/speller/$pkgver/hunspell-en_GB-large-$pkgver.zip
	"

unpack() {
	msg "Unpacking sources..."
	mkdir -p "$builddir"
	cd "$builddir"
	for u in $source; do
		local s="$SRCDEST/$(filename_from_uri $u)"
		unzip $s
	done
}

prepare() {
	cd "$builddir"
	default_prepare
	sed -i "s:SET UTF8:SET UTF-8:g"  *.aff
}

package() {
	cd "$builddir"

	install -dm755 "$pkgdir"/usr/share/hunspell
	install -m644 en_*.dic en_*.aff "$pkgdir"/usr/share/hunspell

	local lang
	for lang in en_AG en_AU en_BS en_BW en_BZ en_DK en_GB en_GH en_HK en_IE en_IN en_JM en_NA en_NG en_NZ en_SG en_TT en_ZA en_ZW; do
		ln -svf en_GB-large.aff "$pkgdir"/usr/share/hunspell/$lang.aff
		ln -svf en_GB-large.dic "$pkgdir"/usr/share/hunspell/$lang.dic
	done
	for lang in en_PH; do
		ln -svf en_US.aff "$pkgdir"/usr/share/hunspell/$lang.aff
		ln -svf en_US.dic "$pkgdir"/usr/share/hunspell/$lang.dic
	done

	# docs
	install -dm755 "$pkgdir"/usr/share/doc/$pkgname
	install -m644 README_en_*.txt "$pkgdir"/usr/share/doc/$pkgname

	# licenses
	install -D -m644 README_en_US.txt "$pkgdir"/usr/share/licenses/$pkgname/Copyright_en_US
	install -D -m644 README_en_CA.txt "$pkgdir"/usr/share/licenses/$pkgname/Copyright_en_CA
	install -D -m644 README_en_GB-large.txt "$pkgdir"/usr/share/licenses/$pkgname/Copyright_en_GB-large
}

sha512sums="14c50a2fd7d390aa1fe20dd1f5e9536bcfd9a36cf829532b340cfc86f72e6415cd41a28e23be67be5a87482bad2af7d7b961524eff10449cad6923518ae0612a  hunspell-en_US-2019.10.06.zip
a2a7526686f950311fdecc24010f4a79081fb2f2e65b588f817e7bcf9e17c902f72139674fa8d7272f16cf43126cd8468f2e38c7edccc9083b8a2916c0026ce0  hunspell-en_CA-2019.10.06.zip
51d9268f02b54804ef364d67e3f38d428abfacac1995186751b2e46477c570653e8fa58fcdc561040a6a03c9aa90631b8c46f3df6250ff04aa7c95a5ef6af886  hunspell-en_GB-large-2019.10.06.zip"
